function openJsonFile(nombre, msj)
{
    createWaiting();
    $.ajax({
        type: "POST",
        url: "./php_jsonOpener.php",
        data:
                {
                    nombre: nombre,
                    req: "abreJSON"
                },
        success: function(data)
        {
            var json = jQuery.parseJSON(data);
            if (json.success)
            {
                var ar = conteando(json.val, new Array(), new Array(), json.msg, 1);
                if (ar[3] == 1)
                    createMsg("Mensaje", msj + "</br>" + json.msg, 2);
                else
                    createMsg("Mensaje", json.msg + "</br>" + ar[2], 3);
            }
            else
                ar = new Array(null, null, null, json.msg, 0);

            pintaSeleccionaPregunta(ar[0], ar[1]);

            closeWaiting();
        }
    });
}
;

function conteando(val, prgts, rspts, msj, t)
{
    var pregunta2 = new Array();
    var numbers = new Array();
    var obj = eval("(" + val + ")");
    var keysbyindex = Object.keys(obj);
    var arrin = Object.keys(obj[keysbyindex[0]]);
    var objIn = obj[keysbyindex[0]];
    var arrinrrin = new Array();
    prgts = new Array();
    for (var i = 0; i < arrin.length; i++)
        arrinrrin.push(Object.keys(objIn[arrin[i]]));
    for (var i = 0; i < arrinrrin.length; i++)
    {
        for (var j = 0; j < arrinrrin[i].length; j++)
        {
            var h1 = arrinrrin[i][j];
            rspts.push(objIn[i][arrinrrin[i][j]]);
            prgts.push(h1);
            if (!isInArray(h1, pregunta2))
            {
                pregunta2.push(h1);
                numbers.push(new Array());
            }
        }
    }
    var mod = pregunta2.length;
    for (var i = 0; i < prgts.length; i++)
    {
        if (i % mod != 0)
        {
            var pos = pregunta2.indexOf(prgts[i]);
            numbers[pos].push(rspts[i]);
        }
    }
    var arr = [pregunta2, numbers, msj, t];
    return arr;
}

function isInArray(value, array)
{
    return array.indexOf(value) > -1;
} 